home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
appshell
/
apputil.bas
< prev
next >
Wrap
BASIC Source File
|
1995-10-23
|
4KB
|
151 lines
DefInt A-Z
Sub GetDefaultPrinter (Win_PrinterName As String, Win_PrinterDriver As String, Win_PrinterPort As String)
'
' get the Windows default printer
'
buf$ = String$(2048, 0)
BufSize% = Len(buf$)
y% = GetProfileString("windows", ByVal "device", "Error", buf$, BufSize%)
If buf$ <> "Error" Then
'
' parse the string
'
i% = InStr(buf$, ",")
j% = InStr(i% + 1, buf$, ",")
Win_PrinterName = Left$(buf$, i% - 1)
Win_PrinterDriver = Mid$(buf$, i% + 1, j% - i% - 1)
Win_PrinterPort = Mid$(buf$, j% + 1)
End If
End Sub
'
' Startup Main Procedure
'
Sub Main ()
'
' Since you cannot assign values like CR and LF to string
' constants, the value of CRLF which is used frequently
' thoughout App Shell when displaying messages, these values are
' are assigned to the global string values of CRLF
'
CRLF = Chr$(13) + Chr$(10)
App_FileExtension = ".TXT"
AppMain.Show
End Sub
Sub pause (seconds As Integer)
Start! = Timer
Finish! = Start! + seconds
Do While Timer < Finish! And Timer > Start!
Loop
End Sub
Sub Place_DialogBox_in_Form (DB As Form, A_Form As Form)
NewLeft! = A_Form.Left + (A_Form.Width \ 2)
If NewLeft! - (DB.Width \ 2) > 0 Then
NewLeft! = NewLeft! - (DB.Width \ 2)
Else
NewLeft! = 0
End If
If NewLeft! + DB.Width > Screen.Width Then
NewLeft! = Screen.Width - DB.Width
End If
NewTop! = A_Form.Top + (A_Form.Height \ 2)
If NewTop! - (DB.Height \ 2) > 0 Then
NewTop! = NewTop! - (DB.Height \ 2)
Else
NewTop! = 0
End If
If NewTop! + DB.Height > Screen.Height Then
NewTop! = Screen.Height - DB.Height
End If
DB.Move NewLeft!, NewTop!
End Sub
'
' Removes various menu items from the System menu of the specified Form.
' Dialog boxes should only have a move and close menu
'
Sub Remove_Items_from_Sysmenu (A_Form As Form)
' Obtain the handle to the forms System menu
'
HSysMenu = GetSystemMenu(A_Form.Hwnd, 0)
' Remove all but the MOVE and CLOSE options. The menu items
' must be removed starting with the last menu item.
'
R = RemoveMenu(HSysMenu, 8, MF_BYPOSITION) 'Switch to
R = RemoveMenu(HSysMenu, 7, MF_BYPOSITION) 'Separator
R = RemoveMenu(HSysMenu, 5, MF_BYPOSITION) 'Separator
End Sub
Sub SplitFileName (fn As String, pqual As String, fqual As String)
Dim LastOne As Integer
'
' split file name into any path entry and file qualifer
'
' find last \ or : in file name
'
test$ = fn
For i% = 1 To Len(test$)
If Mid$(test$, i%, 1) = "\" Or Mid$(test$, i%, 1) = ":" Then
LastOne = i%
End If
Next
Select Case LastOne
Case 0
pqual = ""
fqual = fn
Case 1
pqual = "/"
fqual = Right$(fn, Len(fn) - 1)
Case 2, 3
If Mid$(fn, 2, 1) = ":" Then
pqual = Left$(fn, LastOne)
Else
pqual = Left$(fn, LastOne - 1)
End If
fqual = Right$(fn, Len(fn) - LastOne)
Case Else
pqual = Left$(fn, LastOne - 1)
fqual = Right$(fn, Len(fn) - LastOne)
End Select
End Sub
Sub WriteDefaultPrinter (Win_PrinterName As String, Win_PrinterDriver As String, Win_PrinterPort As String)
'
' write the Windows default printer
'
buf$ = Win_PrinterName + "," + Win_PrinterDriver + "," + Win_PrinterPort
y% = WriteProfileString("windows", "device", ByVal buf$)
'
' notify app of change
'
x& = SendMessage(&HFFFF, WM_WININICHANGE, &H0, ByVal "windows")
End Sub